home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / utilit~1 / tuu103d3.zoo / usr / local / lib / uucp / dial.zyx
Encoding:
Text File  |  1992-12-26  |  2.8 KB  |  168 lines

  1. #!xchat
  2. # @(#) dial.hayes V1.0 Thu Feb 13 14:24:49 1992 (Bob Denny)
  3. #
  4. # xchat script for dialing a vanilla Hayes modem
  5. #
  6. # Usage:
  7. #    xchat dial.hayes telno
  8. #
  9. # where telno is the telephone number, subject to pause and wait
  10. # character modification. 
  11. #
  12. # Uncomment the first two lines after "start:" to get debugging
  13. # in file "debug.log".
  14. #
  15. # Flush input, zero counter, set telephone number if supplied,
  16. # else fail if no telephone number given.
  17. #
  18. start:
  19. #    dbgfile         debug.log
  20. #    dbgset          15 
  21.     zero
  22.     flush
  23.     ifnstr    notelno        0
  24.     telno            0
  25.     goto    initmodem
  26. #
  27. # Missing telephone number.
  28. #
  29. notelno:
  30.     logerr    No telephone number given
  31.     failed
  32. #
  33. # Reset the modem to nonvolatile profile. 
  34. # Allow 3 sec. for response, as some modems are slow to reset.
  35. #
  36. initmodem:
  37.     count
  38.     ifgtr    cantinit    4
  39.     send    ATZ\r
  40.     timeout    initmodem    3000
  41.     expect    setupmodem    OK
  42.     expect    ring        RING\r
  43. #
  44. # No response from modem
  45. #
  46. cantinit:
  47.     logerr    Can't wake modem
  48.     failed
  49. #
  50. # Send the stuff needed to initialize the modem to the modes
  51. # needed for the particular modem flavor. The string below
  52. # is provided as a vanilla example. Allow 2 sec. for the
  53. # modem to respond to this command.
  54. #
  55. setupmodem:
  56.     ifnstr    checkspeed    1
  57.     sleep    1000
  58.     send    at
  59.     sendstr    1        # take parameters from 2nd arg
  60.     send    \r
  61.     timeout    setupfail    2000
  62.     expect    setupfail    ERROR
  63.     expect    checkspeed    OK
  64.     expect    ring        RING\r
  65. #
  66. # Modem barfed or died on setup command.
  67. #
  68. setupfail:
  69.     logerr    Error in modem setup string
  70.     failed
  71. #
  72. # log the line speed to the modem
  73. #
  74. checkspeed:
  75.     send    ats20?\r
  76.     expect    s9600        007\r
  77.     expect    s19200        003\r
  78.     expect    s38400        002\r
  79.     expect    s76800        000\r
  80.     expect    ring        RING\r
  81.     timeout    cspeedfail    2000
  82. #
  83. cspeedfail:
  84.     logerr    speed unkown or < 9600
  85.     goto    dialnumber
  86. #
  87. s9600:
  88.     log    port at 9600 bps
  89.     goto    dialnumber
  90. #
  91. s19200:
  92.     log    port at 19200 bps
  93.     goto    dialnumber
  94. #
  95. s38400:
  96.     log    port at 38400 bps
  97.     goto    dialnumber
  98. #
  99. s76800:
  100.     log    port at 76800 bps
  101.     goto    dialnumber
  102. #
  103. # Dial the supplied number. Handle the various errors that
  104. # can come back from the modem by logging the error.
  105. #
  106. dialnumber:
  107.     zero
  108. retry:
  109.     ifgtr    busy    99    # retry this often before giving up on BUSY
  110.     count
  111.     timeout    atd        3500
  112.     expect    ring        RING\r
  113. #
  114. atd:
  115.     send    ATD
  116.     dial
  117.     send    \r
  118.     flush
  119.     timeout    timeout        90000
  120.     expect    connected    CONNECT\s
  121.     expect    done        CONNECT\r
  122.     expect    done        CONNECT\n
  123.     expect    retry        BUSY
  124.     expect    nocarrier    NO CARRIER
  125.     expect    noanswer    NO ANSWER
  126.     expect    nodialtone    NO DIALTONE
  127.     expect    ring        RING\r
  128. #
  129. # Success!
  130. #
  131. connected:
  132.     timeout done        5000
  133.     logstr    CONNECT
  134.     expect    done        \n
  135. #
  136. done:
  137.     timeout ok        5000
  138.     ifcarr    ok
  139. nocd:
  140.     logerr    CONNECT but no carrier!?
  141. ok:
  142.     success
  143. #
  144. # Handle modem dial failures
  145. #
  146. timeout:
  147.     logerr    Modem or carrier timeout.
  148.     failed
  149. busy:
  150.     logerr    BUSY after 99 retries
  151.     failed
  152. nocarrier:
  153.     logerr    NO CARRIER
  154.     failed
  155. noanswer:
  156.     logerr    NO ANSWER
  157.     failed
  158. nodialtone:
  159.     logerr    NO DIALTONE
  160.     failed
  161. ring:
  162.     logerr    RING
  163.     failed
  164. #
  165. # end
  166. #
  167.  
  168.